<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        onload = () => {
            nub()
        };
        let nub = () => {
            let p1 = document.createElement("h1");
          //  p1.id="changeColor"
            document.body.appendChild(p1);
            setInterval(() => {
                let time = new Date();
                let year = time.getFullYear();
                let month = time.getMonth() + 1;
                let date = time.getDate() < 10 ? "0" + time.getDate() : time.getDate();
                let hour = time.getHours() > 12 ? time.getHours() - 12 : time.getHours();
                let min = time.getMinutes() < 10 ? "0" + time.getMinutes() : time.getMinutes();
                let s = time.getSeconds() < 10 ? "0" + time.getSeconds() : time.getSeconds();
                let ap;
                hour < 12 ? ap = 'PM' : ap = 'AM';
                let week = time.getDay();
                switch (week) {
                    case 1: {
                        week = "一";
                        break
                    }
                    case 2: {
                        week = "二";
                        break
                    }
                    case 3: {
                        week = "三";
                        break
                    }
                    case 4: {
                        week = "四";
                        break
                    }
                    case 5: {
                        week = "五";
                        break
                    }
                    case 6: {
                        week = "六";
                        break
                    }
                    case 7: {
                        week = "日";
                        break
                    }
                }//switch结束
                p1.innerHTML = "<h1>欢迎访问北大青鸟啊！！！</h1>" + "<br>"
                    + year + "年"
                    + month + "月"
                    + date + "日" + "&nbsp;&nbsp;&nbsp;&nbsp;"
                    + hour + ":"
                    + min + ":"
                    + s + "&nbsp;&nbsp;&nbsp;&nbsp;"
                    + ap + "&nbsp;&nbsp;&nbsp;&nbsp;"
                    + "星期" + week
            }, 1000);
            let n=0;
            //变色
            setInterval(()=>{
                n++;
                if (n%2){
                    p1.firstChild.style.color="blue";
                }else {
                    p1.firstChild.style.color="red";
                }

            },10);
        }
    </script>
</head>
<body>

</body>
</html>